#ifndef PAGE_H_
#define PAGE_H_

#include "isr.h"

typedef struct page
{
  u32int present    :1;
  u32int rw         :1;
  u32int user       :1;
  u32int accessed   :1;
  u32int dirty      :1;
  u32int unused     :7;
  u32int frame      :20;
}page_t;

typedef struct page_table
{
    page_t pages[1024];
}page_table_t;

typedef struct page_directory
{
   page_table_t *tables[1024];
   u32int phy_tables[1024];
   u32int phy_addr;
}page_directory_t;

/*
 *  Sets up the environment,page directories etc and enable paging.
 * */
void initialize_paging();


/*
 *load page directory to CR3 register
 * */
void switch_page_directory(page_directory_t *new);

page_t *get_page(u32int address, int make,page_directory_t *dir);

void page_fault(registers_t regs);

void alloc_kernel_frame(page_t* page);
#endif
